﻿using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PS_RoyalItemReceives : System.Web.UI.Page
    {
        private IRoyalItemHistoriesBLL hisBLL = new RoyalItemHistoriesBLL();
        private IRoyalItemRequestBLL reqBLL = new RoyalItemRequestBLL();

        private RoyalItemRequestInfo reqInfo = new RoyalItemRequestInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            //BasicDatePicker1.DisplayType = BasicFrame.WebControls.DatePickerDisplayType.Image; 
        }

        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            //IList<RoyalItemHistoryInfo> infoList = Session["dsSession"];
            List<RoyalItemHistoryInfo> nodeList = (List<RoyalItemHistoryInfo>)Session["dsSession"];
            foreach (RoyalItemHistoryInfo node in nodeList)
            {
                IList<RoyalItemRequestInfo> reqList = reqBLL.ListRoyalItemRequestBySequence(node.Sequence);
                reqInfo = reqList[0];

                hisBLL.Insert(reqInfo.Employee.Sequence.ToString()
                    , Int32.Parse(node.Sequence.ToString())
                    , reqInfo.RoyalItem.Sequence.ToString()
                    , DateTime.Parse(txtReceiveDate.TextWithLiterals.Trim())
                    , reqInfo.Position.RefNo
                    , reqInfo.Position.Name
                    , reqInfo.Class.Name
                    , reqInfo.Salary
                    , reqInfo.JobSite.Name
                    , txtGazetteNo1.Text.Trim()
                    , txtGazetteNo2.Text.Trim()
                    , txtGazetteNo3.Text.Trim()
                    , txtGazetteNo4.Text.Trim()
                    , txtGazetteNo5.Text.Trim()
                    , DateTime.Parse(txtGazetteDate.TextWithLiterals.Trim())
                    , DateTime.Parse(txtRoyalDate.TextWithLiterals.Trim())
                    , 1);
            }

            RadAjaxManager1.ResponseScripts.Add(@"CloseWindow();");
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {

        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }
    }
}
